Reduce LEDSTRIP timer clock to match CPU clock #4805
Merged
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LEDSTRIP timer frequency has value to of 24MHz. On F3 (timer clock 72MHz) this yields prescaler of 3 and everything works normally.
However on F405 (timer clock either 168 or 84 MHz) this may yield a non-integer prescaler of 3.5 on certain timers.
INAV 2.1 used truncation and yielded LEDSTRIP carrier frequency of 933KHz.
INAV 2.2 uses proper rounding and generates LEDSTRIP carrier of 700KHz.
WS2811 expects carrier of 800KHz and based on individual chip tolerances may work (or not work) with different frequency.
This PR lowers timer frequency to 2.4MHz and ensures that integer prescaler is calculated for the following timer clocks: 72 MHz (F3); 84, 168 (F405), 108, 216 (F722).
On F411 operating at 84MHz CPU clock on certain timers this will generate a prescaler of 17.5 (rounded up to 18), but this will yield carrier frequency of 778kHz which should be close enough.
Fixes #4783